package com.nutrition.health.controller;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 测试控制器
 * 用于验证基本的REST功能
 */
@RestController
@RequestMapping("/test")
public class TestController {

    /**
     * 简单的测试端点
     * @return 测试响应
     */
    @GetMapping
    public ResponseEntity<Map<String, Object>> test() {
        Map<String, Object> response = new HashMap<>();
        response.put("message", "API测试成功");
        response.put("timestamp", new Date().toString());
        return ResponseEntity.ok(response);
    }
    
    /**
     * 健康检查端点
     * @return 健康状态
     */
    @GetMapping("/health")
    public ResponseEntity<Map<String, Object>> health() {
        Map<String, Object> status = new HashMap<>();
        status.put("status", "UP");
        status.put("timestamp", new Date().toString());
        
        Map<String, Object> details = new HashMap<>();
        details.put("database", "UP");
        details.put("diskSpace", "UP");
        
        status.put("details", details);
        
        return ResponseEntity.ok(status);
    }
}